<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\indexController;
use App\Http\Controllers\registerController;
use App\Http\Controllers\deleteController;
use App\Models\BlogModel;
use App\Http\Controllers\commentController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//页面显示
Route::get('/',[indexController::class,'article_list']);
Route::get('/detail',[indexController::class,'detail']);
Route::get('/mine',[registerController::class,'mine']);
Route::get('index',[indexController::class,'index'])->name('index');
Route::get('/admin',[indexController::class,'admin'])->middleware('auth:admin');
Route::get('/detail2',[indexController::class,'detail2'])->middleware('auth:admin');

//注册
Route::view('/reg','reg');
Route::post('/register',[registerController::class,'register']);
//登录
Route::post('/login',[registerController::class,'login']);
//退出
Route::get('/loginout',[registerController::class,'loginout']);

//文章增删改查
Route::group(['middleware' => 'auth:admin'],function (){
    Route::get('/delete',[deleteController::class,'delete']);
    Route::post('/add',[deleteController::class,'add']);
    Route::post('/update',[deleteController::class,'update']);
});


//评论
Route::post('/comment',[commentController::class,'comment'])->middleware('auth:admin');
//删除评论
Route::get('/deletcomment',[commentController::class,'deletcomment'])->middleware('auth:admin');

// 首页导航栏搜索
Route::post('/search',[indexController::class,'search']);


//测试
Route::get('/test',function (){
    $user = Auth::user('admin');
    $data = BlogModel::get();
    return view('layouts.app',compact('user'));
//dd($user);
//dd($data);

});





